<!--
 * @Description: 
 * @Version: 1.0.0
 * @Author: gyh
 * @Date: 2021-08-18 10:18:28
 * @LastEditors: gyh
 * @LastEditTime: 2021-08-18 11:14:25
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>节流防抖事件</title>
    <style>
      #totop {
        display: none;
        position: fixed;
        right: 20px;
        bottom: 20px;
        width: 45px;
        height: 45px;
        text-align: center;
        background-color: #f60;
        color: #fff;
      }
    </style>
  </head>
  <body>
    <input id="input" type="text" />
    <ul id="list"></ul>
    <div id="totop">返回顶部</div>
    <script>
      let listNode = document.getElementById('list')
      let frag = document.createDocumentFragment()
      for (let i = 0, count = 100, li; i < count; i++) {
        li = document.createElement('li')
        li.innerHTML = `这是第${i + 1}个元素`
        frag.appendChild(li)
      }
      listNode.appendChild(frag)
    </script>
    <script src="./throttle.js"></script>
    <script src="./debounce.js"></script>
  </body>
</html>
